package vcp.entity;

import java.util.Comparator;

import org.joda.time.DateTime;

import vcp.enums.SiteEnum;

/**
 * 
 * @author VCP team
 *         <p>
 *         class responsible for holding DB entry data from dayStatic table
 *         </p>
 */
public class DayStatistics
{
	// ****************************************************************************************************************************
	// Static methods
	// ****************************************************************************************************************************
	public static Comparator <DayStatistics> createUsedCompartor ()
	{
		return new DayStatistics().new DayStatisticsUsedComparator();
	}

	public static Comparator <DayStatistics> createCanceledCompartor ()
	{
		return new DayStatistics().new DayStatisticsCanceledComparator();
	}

	// ****************************************************************************************************************************
	// Setter-Getter methods
	// ****************************************************************************************************************************

	private int ID;

	/**
	 * getter
	 * 
	 * @return ID
	 */
	public int getID ()
	{
		return this.ID;
	}

	/**
	 * setter
	 * 
	 * @param iD
	 *            set new ID
	 */
	public void setID ( int iD )
	{
		this.ID = iD;
	}

	private int numOfUsedOrders;

	/**
	 * getter
	 * 
	 * @return number of used orders
	 */
	public int getNumOfUsedOrders ()
	{
		return this.numOfUsedOrders;
	}

	/**
	 * setter
	 * 
	 * @param numOfUsedOrder
	 *            set new number of used orders
	 */
	public void setNumOfUsedOrders ( int numOfUsedOrder )
	{
		this.numOfUsedOrders = numOfUsedOrder;
	}

	private int numOfCanceledOrders;

	/**
	 * getter
	 * 
	 * @return number of canceled orders
	 */
	public int getNumOfCanceledOrders ()
	{
		return this.numOfCanceledOrders;
	}

	/**
	 * setter
	 * 
	 * @param numOfCanceledOrders
	 *            set new number of canceled orders
	 */
	public void setNumOfCanceledOrders ( int numOfCanceledOrders )
	{
		this.numOfCanceledOrders = numOfCanceledOrders;
	}

	private int numOfSubscription;

	/**
	 * getter
	 * 
	 * @return number of subscriptions
	 */
	public int getNumOfSubscription ()
	{
		return this.numOfSubscription;
	}

	/**
	 * setter
	 * 
	 * @param numOfSubscription
	 *            set new number of subscriptions
	 */
	public void setNumOfSubscription ( int numOfSubscription )
	{
		this.numOfSubscription = numOfSubscription;
	}

	private int numOfBussinessClass;

	/**
	 * getter
	 * 
	 * @return number of business class
	 */
	public int getNumOfBussinessClass ()
	{
		return this.numOfBussinessClass;
	}

	/**
	 * setter
	 * 
	 * @param numOfBussinessClass
	 *            set new number of business class
	 */
	public void setNumOfBussinessClass ( int numOfBussinessClass )
	{
		this.numOfBussinessClass = numOfBussinessClass;
	}

	private int numOfParkingLates;

	/**
	 * getter
	 * 
	 * @return number of parking lates
	 */
	public int getNumOfParkingLates ()
	{
		return this.numOfParkingLates;
	}

	/**
	 * setter
	 * 
	 * @param numOfParkingLates
	 *            sets new number of parking lates
	 */
	public void setNumOfParkingLates ( int numOfParkingLates )
	{
		this.numOfParkingLates = numOfParkingLates;
	}

	private DateTime date;

	/**
	 * 
	 * @return report creation date
	 */
	public DateTime getDate ()
	{
		return this.date;
	}

	/**
	 * 
	 * @param date
	 *            new date for report
	 */
	public void setDate ( DateTime date )
	{
		this.date = date;
	}

	private SiteEnum siteEnum;

	/**
	 * 
	 * @return site enum representation
	 */
	public SiteEnum getSiteEnum ()
	{
		return this.siteEnum;
	}

	/**
	 * new site enum
	 * 
	 * @param siteEnum
	 */
	public void setSiteEnum ( SiteEnum siteEnum )
	{
		this.siteEnum = siteEnum;
	}

	// ****************************************************************************************************************************
	// Private Comparator classes
	// ****************************************************************************************************************************
	/**
	 * 
	 * @author VCP team
	 *         <p>
	 *         DayStatistics comparator according to used
	 *         </p>
	 */
	private class DayStatisticsUsedComparator implements Comparator <DayStatistics>
	{
		@Override
		public int compare ( DayStatistics day1, DayStatistics day2 )
		{
			int result = 0;
			if ( day1.getNumOfUsedOrders() < day2.getNumOfUsedOrders() )
			{
				result = - 1;
			}
			else if ( day1.getNumOfUsedOrders() > day2.getNumOfUsedOrders() )
			{
				result = 1;
			}
			else
			{
				result = 0;
			}
			return result;
		}
	}

	/**
	 * 
	 * @author VCP team
	 *         <p>
	 *         DayStatistics comparator according to used
	 *         </p>
	 */
	private class DayStatisticsCanceledComparator implements Comparator <DayStatistics>
	{

		@Override
		public int compare ( DayStatistics day1, DayStatistics day2 )
		{
			int result = 0;
			if ( day1.getNumOfCanceledOrders() < day2.getNumOfCanceledOrders() )
			{
				result = - 1;
			}
			else if ( day1.getNumOfCanceledOrders() > day2.getNumOfCanceledOrders() )
			{
				result = 1;
			}
			else
			{
				result = 0;
			}
			return result;
		}

	}
}
